Socket
Socket
Sign inDemoInstall

warning

Package Overview
Dependencies
2
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    warning

A mirror of Facebook's Warning


Version published
Weekly downloads
8.9M
increased by1.68%
Maintainers
1
Install size
30.8 kB
Created
Weekly downloads
 

Package description

What is warning?

The 'warning' npm package is a utility that allows developers to print warning messages to the console. It is typically used to alert developers of potential issues or misuses of an API that are not severe enough to warrant throwing an error. It is often used in development environments to provide guidance without interrupting the execution of the program.

What are warning's main functionalities?

Conditional warnings

This feature allows developers to conditionally display warning messages based on a boolean condition. If the condition is true, the warning message is printed to the console.

var warning = require('warning');

var shouldWarn = true;
warning(shouldWarn, 'This is a warning message that will only be displayed if shouldWarn is true.');

Other packages similar to warning

Changelog

Source

3.0.0 (2015-10-04)

BREAKING CHANGE

  • package.json correct license field (6bd7ad5)

<a name="2.1.0"></a>

Readme

Source

Warning npm version

A mirror of Facebook's Warning

Usage

npm install warning
// some script
var warning = require('warning');

var ShouldBeTrue = false;

warning(
  ShouldBeTrue,
  'This thing should be true but you set to false. No soup for you!'
);
//  'This thing should be true but you set to false. No soup for you!'

Similar to Facebook's invariant but only logs a warning if the condition is not met. This can be used to log issues in development environments in critical paths. Removing the logging code for production environments will keep the same logic and follow the same code paths.

Browserify

When using browserify, the browser.js file will be imported instead of invariant.js and browserify will be told to transform the file with envify. The only difference between browser.js and invariant.js is the process.env.NODE_ENV variable isn't cached. This, in combination with envify and (optionally) uglifyjs, will result in a noop in production environments. Otherwise behavior is as expected.

Use in Production

It is recommended to add babel-plugin-dev-expression with this module to remove warning messages in production.
















Don't Forget To Be Awesome

Keywords

FAQs

Last updated on 03 Jun 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc